#include "ThreadPool.hpp"
#include "Task.hpp"
#include <ctime>
#include <unistd.h>

int main()
{
    srand(time(nullptr));

    std::cout << "process run... " << std::endl;
    sleep(3);
    ThreadPool<Task>::GetInstance()->Start();

    while (true)
    {
        // 1.构建任务
        int x = rand() % 10 + 1;
        usleep(10);
        int y = rand() % 10;
        char op = opers[rand() % opers.size()];

        Task t(x, y, op);
        ThreadPool<Task>::GetInstance()->Push(t);
        // 2.交给线程池处理
        std::cout << "main thread make task: " << t.GetTask() << std::endl;
 
        sleep(1);
    }

    return 0;
}